﻿// <copyright file="XValueLookup.cs" company="http://www.dymetis.com">
//
// Copyright (c) 2011 Eddie Z. Lin.
//
// This source is subject to the Microsoft Public License.
// See http://www.opensource.org/licenses/ms-pl.
// All other rights reserved.
// 
// </copyright>

namespace Dymetis.Expressions
{
    using System.Xml.Linq;
    using System.Xml.XPath;

    internal class XValueLookup : IValueLookup
    {
        private readonly XNode node;

        public XValueLookup(XNode node)
        {
            this.node = node;
        }

        public object GetValue(string name)
        {
            var parameterNode = this.node.XPathSelectElement(name);
            return parameterNode == null ? null : parameterNode.Value;
        }
    }
}
